<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>date的用法，时间走动</title>
		<script>
			 var myTimer;
			function showTime()
			{
				var d1=new Date();
			    var str=d1.getHours()+":"+d1.getMinutes()+":"+d1.getSeconds();
			    document.getElementById("time").innerHTML=str;
			}
			function init()
			{
				showTime();
				//window.setTimeout("showTime()",1000);
				myTimer=window.setInterval("showTime()",1000);
			}
			function stopTime()
			{
				window.clearInterval(myTimer);
			}
		</script>
	</head>
	<body onload="init()">
		<div id="time"></div>
		<input type="button" value="stop" onclick="stopTime()"/>
	</body>
</html>
